package com.lg.partition28;

import java.io.*;

/**
 * 关于为什么不能在递归同时输出的问题：https://www.luogu.com.cn/blog/countercurrent-time/solution-p2731
 * @author `RKC`
 * @date 2022/4/23 9:18
 */
public class P2731USACO3_骑马修栅栏 {

    private static final int N = 510, M = 1100;
    private static int[][] g = new int[N][N];
    private static int[] deg = new int[N], stk = new int[M];
    private static int m, top = 0;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        m = nextInt();
        for (int i = 0; i < m; i++) {
            int u = nextInt(), v = nextInt();
            g[u][v]++;
            g[v][u]++;
            deg[u]++;
            deg[v]++;
        }
        int root = 1;
        for (int i = 1; i < N; i++) {
            if ((deg[i] & 1) == 1) {
                root = i;
                break;
            }
        }
        dfs(root);
        for (int i = top; i >= 1; i--) writer.println(stk[i]);
        writer.flush();
    }

    private static void dfs(int u) {
        for (int i = 1; i < N; i++) {
            if (g[u][i] > 0) {
                g[u][i]--;
                g[i][u]--;
                dfs(i);
            }
        }
        stk[++top] = u;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
